<template>
	<div>
		<el-container>
			<el-header>医院门诊信息管理系统</el-header>
			<el-container class="home-contain">			
				<el-aside width="200px">
		    	<el-menu default-active="2" router
      	class="el-menu-vertical-demo">
      		<template v-for="(menu,i) in menus">
			      <el-submenu :index="i+1" >
				  <!-- <el-submenu :index="i+1"  :disabled="menu.id===type2?false:true"> -->
			        <template slot="title" >	
			          <i class="el-icon-user-solid"></i>
			          <span>{{menu.name}}</span>
			        </template>
			        <el-menu-item-group>    
			        	<template v-for="submenu in menu.submenu">
			          	<el-menu-item :index="submenu.url">{{submenu.name}}</el-menu-item>
			          </template>
			        </el-menu-item-group> 
			      </el-submenu>
			    </template>
			    </el-menu>
		    </el-aside>
				<el-main>
					<router-view />
				</el-main>
			</el-container>
		</el-container>
	</div>
</template>

<script>
	import {
		showMsgTitle
	} from '@/utils/api'
	import {
		showMsgConfirm
	} from '@/utils/api'
	import {
		getRequest
	} from '@/utils/api'
	export default {
		mounted: function() {
			let url = "/menu";
			let _this = this;
			getRequest(url).then(resp => {
				if (resp.status == 200) {
					_this.menus = resp.data;
				} else {
					_this.$message({
						type: 'error',
						message: '数据加载失败!'
					});
				}
			}, resp => {
				_this.loading = false;
				if (resp.response.status == 403) {
					_this.$message({
						type: 'error',
						message: resp.response.data
					});
				} else {
					_this.$message({
						type: 'error',
						message: '数据加载失败!'
					});
				}
			}).catch(resp => {
				//压根没见到服务器
				_this.loading = false;
				_this.$message({
					type: 'error',
					message: '数据加载失败!'
				});
			});
			var type1 = this.$route.query.type;
			console.log(this.$route.query.type);			
			this.type2=type1+"";
			// var user=this.$route.query.user;
			// this.$router.push({
			// 	path: '/registration',
			// 	query: {
			// 		user:user
			// 	},
			// 	replace: true
			// });
		},
		methods: {
			handleOpen(key, keyPath) {
				console.log(key, keyPath);
			},
			handleClose(key, keyPath) {
				console.log(key, keyPath);
			}
		},
		data() {
			return {
				menus: [{
					name: "",
					submenu: [{
						name: '',
						url: ''					
					}],
					id:''
				}],
				type2:"",
			}
		}
	}
</script>
<style scoped>
	.home_main {
		background-color: #ff0;
		color: #000;
	}

	.home-contain {
		display: flex;
	}
</style>
